<?php

namespace Biz\model\Album;

use Doraemon\pockets\datebase\BaseDbModel;

class AlbumCategoryRelateModel extends BaseDbModel
{
    const _CONFIG_FILE_ = 'db_store';

    const _CONFIG_SELECT_ = 'db_store';

    const _DATABASE_ = 'store';

    public const _TABLE_NAME = 'album_category_relate';

    const STATUS_NORMAL = 1;
    // 状态为删除
    const STATUS_DELETE = 9;

    public static function insertData($data)
    {
        $ret = self::insert($data);
        if ($ret->errorCode() !== '00000') {
            return false;
        }

        return self::id();
    }

    public static function updateDataByWhere($data, $where)
    {
        if (!isset($data['edittime'])) {
            $data['edittime'] = date('Y-m-d H:i:s');
        }
        $ret = self::update($data, $where);
        if ($ret->errorCode() !== '00000') {
            return false;
        }

        return true;
    }
    public static function updateByWhere($data , $where): int
    {
        if(!isset($data['edittime'])){
            $data['edittime'] = date('Y-m-d H:i:s');
        }
        return self::update($data , $where)->rowCount();
    }

    public static function selectByWhere($where, $field = '*')
    {
        return self::select($field, $where) ?? [];
    }

    public static function getByWhere($field, $where = [])
    {
        return self::get($field, $where);
    }

}